<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>修改密码</title> 
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<link href="${ctx}/css/style.css" rel="stylesheet" type="text/css" />

	<!-- 通用框架 -->
	<script src="${ctx}/js/My97DatePicker/WdatePicker.js" type="text/javascript" ></script>	
    <script src="${ctx}/js/jqGrid/js/jquery-1.6.2.min.js" type="text/javascript" ></script> 
    <script src="${ctx}/js/jquery.form.js" type="text/javascript"></script>

    <!-- 验证框架 --> 

    <script src="${ctx}/js/json2.js" type="text/javascript"></script>
    <script src="${ctx}/js/CM.js" type="text/javascript"></script>

  </head>
<body>
<form method="post" name="mainform" id="mainform">
	<input type="hidden" id="micet_returnurl" name="micet_returnurl" value="userController/showmenus.do"/>
	<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td align="center" valign="top">
				<table class="TabMain" BORDER="0" CELLPADDING="0" CELLSPACING="0">
					<tr>
						<td align="center" valign="top">
							<table width="100%" border="0">
								<tr class="TabMain">
									<td height="30" align="center">
										<span class="tab_title">修改密码</span>
									</td>
								</tr>
							</table>
							<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tab1">
								<!-- <tr class="tr1" id="tr_loginname">
									<td align="center" width="50%" nowrap class="td1">登录名</td>
									<td align="left" nowrap bgcolor="#FFFFFF">
										<input id="loginname" name="loginname" />
									</td>
								</tr> -->
								<tr class="tr1" id="tr_password">
									<td align="center" nowrap class="td1">原密码</td>
									<td align="left" nowrap bgcolor="#FFFFFF">
										<input type="password" id="oldpassword" name="oldpassword" />
									</td>
								</tr>
								<tr class="tr1" id="tr_realname">
									<td align="center" nowrap class="td1">新密码</td>
									<td align="left" nowrap bgcolor="#FFFFFF">
										<input type="password" id="loginpassword" name="loginpassword" />

									</td>
								</tr>
								<tr class="tr1" id="tr_photo">
									<td align="center" nowrap class="td1">确认密码</td>
									<td align="left" nowrap bgcolor="#FFFFFF">
										<input type="password" id="loginpassword2" name="loginpassword2" />
									</td>
								</tr>
							</table>
						</TD>
					</TR>
					<TR>
						<TD height="40" align="center">
							<input name="bt_ok" id="bt_ok" type="button" class="b2_ok" onClick="f_save();" value="确定">
							<input name="bt_cancel" id="bt_cancel" type="button" class="b2_cancel" onClick="f_cancel();" value="取消">
						</TD>
					</TR>
				</TABLE>
			</td>
		</tr>
	</table>
</form>
	<script type="text/javascript">
	$(document).ready(function(){ 
		jQuery("#mainform").validationEngine({
			promptPosition:"topLeft"
			});
		f_loaded();
	});
	</script>
    <script type="text/javascript">
		function f_save() {
			/* 角色 */
			var loginname = CM.cookies.get("loginname");
			var password = CM.cookies.get("password");
			
			var tmploginpassword = $("#loginpassword").val();
			var oldpassword = $("#oldpassword").val();
			var tmploginpassword2 = $("#loginpassword2").val();
			if(oldpassword != password){
				alert("原密码输入错误!");
				return;
			}
			if(tmploginpassword!=tmploginpassword2){
				alert("新密码和确认密码不一致!");
				return;
			}
	        jQuery.ajax({  
		         type : 'POST',  
		         url : 'userController/changepassword.do',  
		         data :'newpassword='+tmploginpassword,  
		         dataType : 'text',
		         success : function(data) {  
		           alert("密码修改成功!"); 
		           window.close();
		         },  
		         error : function(data) {  
		           alert("密码修改失败!")  
		         }  
		     });
	         
		}
		
		 /* 返回 */
		 function f_cancel(){
			 window.close();
		 }

  </script>
</body>
</html>

